import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

/// https的配置
class HttpConfig {
  /// 请求的地址baseUrl
  static const String _devBaseUrl = 'http://dev.com';
  static const String _prodBaseUrl = 'https://prop.com';

  /// 我们使用的请求地址
  static String get baseUrl {
    if (kDebugMode) {
      return _devBaseUrl;
    } else {
      return _prodBaseUrl;
    }
  }

  /// 后台请求成功的code
  static const int successCode = 0;

  /// 连接超时时间
  static const int connectTimeOut = 10 * 1000;

  /// 发送超时时间
  static const int sendTimeOut = 10 * 1000;

  /// 最大连接数
  static const int maxRedirects = 10;

  /// 常用的 content-type 请求头
  static const String jsonContentType = Headers.jsonContentType;
  static const String textPlainContentType = Headers.textPlainContentType;
  static const String formUrlEncodedContentType =
      Headers.formUrlEncodedContentType;
  static const String multipartFormDataContentType =
      Headers.multipartFormDataContentType;

  /// token失效需要刷新token的返回code
  static const List<int> refreshTokenCodes = [401, 402];
}
